<%@ page import="com.ttl.common.menu.MenuBean, 
				java.util.*,
				com.ttl.common.usermenu.UserBean,
				com.ttl.common.usermenu.Menu2Bean" %>
<html>

<head>
	<title>Destroydrop &raquo; Javascripts &raquo; Tree</title>

	<link rel="StyleSheet" href="<%= request.getContextPath() %>/css/dtree/dtree.css" type="text/css" />
	<script type="text/javascript" src="<%= request.getContextPath() %>/css/dtree/dtree.js"></script>
	<link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/css/me.css" />
</head>

<body bgcolor="#DAE3EB" leftmargin="0" topmargin="0" >

<div class="dtree" >

	<p><a href="javascript: d.openAll();">Open all</a> | <a href="javascript: d.closeAll();">Close all</a></p>

	<script type="text/javascript">
/*		d = new dTree('d');

		d.add(0,-1,'My example tree');		
		d.add(1,0,'Node 1','');
		d.add(2,0,'Node 2','/ittl/StkReq.do?mode=blank');
		d.add(3,1,'Node 1.1','');
		d.add(4,0,'Node 3','example01.html');
		d.add(5,3,'Node 1.1.1','');
		d.add(6,5,'Node 1.1.1.1','example01.html');
		d.add(7,0,'Node 4','example01.html');
		d.add(8,1,'Node 1.2','example01.html');
		d.add(9,0,'My Pictures','','Pictures I\'ve taken over the years','','','img/imgfolder.gif');
		d.add(10,9,'The trip to Iceland','example01.html','Pictures of Gullfoss and Geysir');
		d.add(11,9,'Mom\'s birthday','example01.html');
		d.add(12,0,'Recycle Bin','example01.html','','','img/trash.gif');						
		document.write(d);
*/
	</script>

<% 
	out.print("<script type='text/javascript'>");
	out.print("d = new dTree('d');");
	out.print("d.add(0,-1,'My Menu');");
	
	TreeSet menu2 = new TreeSet();
	
	Set userMenuSet = (Set)request.getSession().getAttribute("userMenu");
	Iterator it = userMenuSet.iterator();
	
	List<Menu2Bean> listExam = new ArrayList<Menu2Bean>();
    while(it.hasNext()) {
    	Menu2Bean mb = (Menu2Bean)it.next();
    	
    	listExam.add(mb);
    	
//    	menu2.add(mb);
//		out.print("d.add("+mb.getId()+","+mb.getParent_id()+",'"+mb.getName()+"'"+",'"+mb.getLocation()+"');");				
    }
    Collections.sort(listExam);
    for(Menu2Bean mb : listExam){
    	out.print("d.add("+mb.getId()+","+mb.getParent_id()+",'"+mb.getName()+"'"+",'"+mb.getLocation()+"');");
    }    
//    Iterator it2 = menu2.iterator();
//    while(it2.hasNext()) {
//    	Menu2Bean mb = (Menu2Bean)it2.next();
//    	out.print("d.add("+mb.getId()+","+mb.getParent_id()+",'"+mb.getName()+"'"+",'"+mb.getLocation()+"');");
//    }
    
    
/*	
	out.print("d.add(1,0,'Node tree 1','');");
	out.print("d.add(2,0,'Node 2','/ittl/StkReq.do?mode=blank');");
	out.print("d.add(3,1,'Node 1.1','');");
	out.print("d.add(4,0,'Node 3','example01.html');");
	out.print("d.add(5,3,'Node 1.1.1','');");
*/		
	out.print("document.write(d);");
	out.print("</script>");
%>
</div>

<div id="source">
  User:<%= request.getSession().getAttribute("userName") %>,
  Dept.: <%= request.getSession().getAttribute("departCode") %>
</div>



</body>
</html>